Initializes a new instance of the DelegateVerifier class.
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim errorMessage As String
Dim verifierCondition As IdeaBlade.Validation.VerifierCondition(Of T)
Dim instance As New DelegateVerifier(Of T)(errorMessage, verifierCondition) |
Parameters
- errorMessage
- Error message for failed verification
- verifierCondition
- Defines the verification to be performed
Example
C# | Copy Code |
---|
private DelegateVerifier SampleDelegateVerifier() {
// A simple example adding a delegate verifier for the Employee HireDate property.
// This verifier could more easily be handled using a DateTimeRangeVerifier,
// but is intended to show the parts to a DelegateVerifier.
string errorMessage = "HireDate must be greater than MinValue";
// Define the verification test.
VerifierCondition<Employee> condition = (emp, trigger, ctx) => {
// Note when executed before the property is set that we must inspect the ProposedValue.
DateTime? hireDate = (trigger.Timing == TriggerTiming.BeforeSet) ? (DateTime?) trigger.ProposedValue : emp.HireDate;
return new VerifierResult(hireDate >= DateTime.Parse("1/1/2000"));
};
// Create the verifier.
var v = new DelegateVerifier<Employee>(errorMessage, condition);
// Add a trigger - here it's the HireDate property.
v.AddTrigger(Employee.PropertyMetadata.HireDate.Name);
return v;
} |
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also